export default {
  data() {
    return {
      formInline: {
        loginId: "",
        password: "",
        checkbox: [],
      },
      ruleInline: {
        password: [
          {
            type: "string",
            min: 6,
            message: "密码长度不能少于6位!",
            trigger: "blur",
          },
        ],
      },
    };
  },
  computed: {
    user() {
      return this.$store.state.user;
    },
  },
  created() {
    var query = this.$route.query;
    console.log("query:" + JSON.stringify(query));
    var isExit = query.isExit;
    if (isExit && isExit == "true") {
      localStorage.clear();
      this.$store.commit("clearUser");
    }
    this.isLogined();
  },
  methods: {
    isLogined() {
      this.$LoginAction.isLogin(this.user);
    },
    login() {
      this.$axios({
        url: "login",
        method: "POST",
        data: {
          loginId: this.formInline.loginId,
          password: this.formInline.password,
        },
      }).then((res) => {
        if (res.code == 200) {
          this.$store.commit("setUseInfo", {
            uid: res.data.uid,
            name: res.data.name,
            // type: res.data.utype,
            // schId: res.data.schId,
          });
          localStorage.setItem("token", res.data.token);
          this.isLogined();
        } else {
          this.$Message.error(res.msg);
        }
      });
    },
  },
};
